package com.example.sportplay.controller;

import com.alibaba.fastjson.JSON;
import com.example.sportplay.bean.Jiaofei;
import com.example.sportplay.bean.User;
import com.example.sportplay.dao.CarDao;
import com.example.sportplay.dao.JiaofeiDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.List;

public class JiaofeiController {

    @Autowired
    private JiaofeiDao jiaofeidao;
    @Autowired
    private CarDao carDao;
    @CrossOrigin
    //@RequestMapping("/getAllJiaofei")
    @RequestMapping("/jflist")
    public String getAllJiaofei(){


        List<User> allJiaofei = jiaofeidao.getAllJiaofei();

        HashMap<String, Object> res = new HashMap<>();

        res.put("data",allJiaofei);

        String users_json = JSON.toJSONString(res);
        System.out.println(allJiaofei);
        System.out.println("1111111111111111111111111111111111111111111");
        return users_json;
    }

    @CrossOrigin
    @RequestMapping("/carlist2")
    public String getCarList(){






        List<User> cars = carDao.getAllCar();
        HashMap<String, Object> res = new HashMap<>();

        res.put("data",cars);

        String users_json = JSON.toJSONString(res);
        System.out.println(cars);
        return users_json;
    }
}
